package cn.sstir.api.config;

import cn.sstir.api.interceptor.ApiSignatureInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @title: WebConfig
 * @description: 拦截器配置
 * @author: fli
 * @email: fli@sstir.cn
 * @date: 2019/8/13 15:43
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Bean
    public ApiSignatureInterceptor apiSignatureInterceptor(){
        return new ApiSignatureInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(apiSignatureInterceptor()).excludePathPatterns("/error").addPathPatterns("/**");
    }
}
